home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / js / explorer-src.js < prev    next >
Text File  |  2010-05-19  |  30KB  |  831 lines

  1. function shortName(completeName){
  2.     var p=completeName.lastIndexOf('.');
  3.     if(p>=0) return completeName.substring(0,p);
  4.     return completeName;
  5. }
  6.  
  7.  
  8. // Change files layout
  9. function filesLayoutSet(l){
  10.     var e=wl.button.enable;
  11.     e(dgi('filesLayout_list'));
  12.     e(dgi('filesLayout_icons'));
  13.     e(dgi('filesLayout_resource'));
  14.     wl.button.disable(dgi('filesLayout_'+l));
  15.     efTNSize((l==='list')?-1:undefined);
  16.     fas(false,"filesLayoutSet",l,0,(W.filesListDisplayed && l!='resource')?'async':'sync');
  17. }
  18.  
  19. // Search for a file
  20. var searchFileLast='';
  21. var searchFileDialog;
  22. function searchFile(result){
  23.     if(result){
  24.         searchFileLast=result['input'];
  25.         if(result['button']=='ok' && result['input'].length) {
  26.             //maskShow(false,false,true);
  27.             searchFileDialog.item('icon').src=loadingIconURL;
  28.             wl.button.disable(searchFileDialog.item('ok'))
  29.             searchFileDialog.item('input').disabled=true;
  30.             wl.button.setFunction(searchFileDialog.item('cancel'),'searchFileCancel()');
  31.  
  32.             // Start searching
  33.             fas("","searchFile",result['input'],"");
  34.             return true; // Don't close form
  35.         }
  36.         return;
  37.     }
  38.     searchFileDialog=new dialogBox({'icon':efSearchIcon,'title':efSearchTitle,'text':efSearchText,'input':searchFileLast,'buttons':{'ok':efSearchOkCaption,'cancel':efSearchCancelCaption},'mask':true},'searchFile');
  39.     searchFileDialog.show();
  40.     searchFileDialog.item('input').focus();
  41. }
  42. function searchFileCancel(){
  43.     wl.asr.cancelAll();
  44.     searchFileDialog.hide();
  45.     fas('','searchFileCancel','','');
  46. }
  47. function searchFileComplete(results,totSize){
  48.     fa=results;
  49.     totalSize=totSize;
  50.     insertFiles();
  51.     searchFileDialog.hide();
  52. }
  53.  
  54. // Remote download
  55. function rdl(inputId) {
  56.     var url;
  57.     if((url=dgi(inputId).value)=="") return;
  58.     dgi(inputId).value="";
  59.     fas(url,"rdl","","");
  60. }
  61.  
  62.  
  63. // Multiple downloads / playlist
  64. var mIsProcessing=0;
  65. function mAdd(id){
  66.     if(mIsProcessing) return;
  67.     mProcessing(true);
  68.     // Cancel return-to-position animation
  69.     if(dd && dd.elements[id]) dd.elements[id].cancelAnim=1;
  70.     if(dd && dd.elements['_'+id]) dd.elements['_'+id].cancelAnim=1;
  71.     if(dgi(id)) sendData("data3=mAdd&data2="+encodeURIComponent(dgi(id).innerHTML), PHP_SELF, false);
  72.     else sendData("data3=mAdd&data2="+id, PHP_SELF, false);
  73. }
  74. // Add into opener window/frame
  75. function mAddOpener(id){
  76.     if(parent && winMe.getOpenerId()) parent.frames[parent.dgi(winMe.getOpenerId()+'_if').name].mAdd(id);
  77.     else if(opener && opener.mAdd) opener.mAdd(id);
  78.     else mAdd(id);
  79. }
  80. // Remove from list
  81. function mSupp(id){
  82.     if(mIsProcessing) return;
  83.     mProcessing(true);
  84.     sendData("data3=mSupp&data2="+encodeURIComponent(dgi(id).innerHTML), PHP_SELF, false);
  85. }
  86. // Remove all
  87. function mSuppAll(){
  88.     if(mIsProcessing) return;
  89.     mProcessing(true);
  90.     sendData("data3=mSuppAll", PHP_SELF, false);
  91. }
  92. // Add all current dir's files
  93. function mAddAll(){
  94.     if(mIsProcessing) return;
  95.     mProcessing(true);
  96.     sendData("data3=mAddAll", PHP_SELF, false);
  97. }
  98. // Start download of all selected files
  99. function mDownload(){
  100.     if(mIsProcessing) return;
  101.     var prevT=D.forms.comForm.target;
  102.     D.forms.comForm.target="_self";
  103.     if(dgi("transfersIFrame")) setTimeout("updateTransfersIframe()",1000);
  104.     fas('','mDownload',false,false,'sync');
  105.     D.forms.comForm.target=prevT;
  106. }
  107. function btDownload(){
  108.     if(mIsProcessing) return;
  109.     if(dgi("transfersIFrame")) setTimeout("updateTransfersIframe(0)",5000);
  110.     D.forms.comForm.target="_self";
  111.     fas('','btDownload','','','sync');
  112. }
  113. function mProcessing(isProcessing){
  114.     var a=dgi('mdlIcon'), b=dgi('mdlLoadingIcon'),c=dgi('mDlList');
  115.     if(isProcessing){
  116.         mIsProcessing=1;
  117.         if(a) {a.style.display="none"; b.style.display="";}
  118.         if(c) c.style.cursor='wait';
  119.     }
  120.     else{
  121.         mIsProcessing=0;
  122.         if(a) {b.style.display="none"; a.style.display="";}
  123.         if(c) c.style.cursor='auto';
  124.     }
  125. }
  126. function mToggleButtons(enabled){
  127.     if(enabled){
  128.         wl.button.enable("plPlayM3UBt");
  129.         if(dgi("plPlayAllBtE") && dgi("plPlayAllBtD")) {dgi("plPlayAllBtE").style.display="inline"; dgi("plPlayAllBtD").style.display="none";}
  130.         if(dgi("mDlDownloadE") && dgi("mDlDownloadD")) {dgi("mDlDownloadE").style.display="inline"; dgi("mDlDownloadD").style.display="none";}
  131.         if(dgi("btDlDownloadE") && dgi("btDlDownloadD")) {dgi("btDlDownloadE").style.display="inline"; dgi("btDlDownloadD").style.display="none";}
  132.         if(dgi("mDlClearE") && dgi("mDlClearD"))  {dgi("mDlClearE").style.display="inline";dgi("mDlClearD").style.display="none";}
  133.     }
  134.     else{
  135.         wl.button.disable("plPlayM3UBt");
  136.         if(dgi("plPlayAllBtE") && dgi("plPlayAllBtD")) {dgi("plPlayAllBtE").style.display="none"; dgi("plPlayAllBtD").style.display="inline";}
  137.         if(dgi("mDlDownloadE") && dgi("mDlDownloadD")) {dgi("mDlDownloadE").style.display="none"; dgi("mDlDownloadD").style.display="inline";}
  138.         if(dgi("btDlDownloadE") && dgi("btDlDownloadD")) {dgi("btDlDownloadE").style.display="none"; dgi("btDlDownloadD").style.display="inline";}
  139.         if(dgi("mDlClearE") && dgi("mDlClearD"))  {dgi("mDlClearE").style.display="none";dgi("mDlClearD").style.display="inline";}
  140.     }
  141. }
  142.  
  143. // Delete a file or a folder
  144. function sup(id) {
  145.     if(!dgi(id)) return;
  146.     if(!confirm(efCaptGenConfirmSuppress.replace('%1',dgi(id).innerHTML))) return;
  147.     fas(dgi(id).innerHTML,"sup","","");
  148.     asyncSetPI(1);
  149. }
  150. // Rename a file or folder
  151. function ren(id) {
  152.     oldName=dgi(id).innerHTML.replace(/ /g,' ').replace(/&/g,'&');
  153.     newName=prompt(efCaptExplorerEnterNewName,oldName);
  154.     if ((newName) && (newName!="")) fas(oldName.replace(/&/g,'&'),"ren", newName.replace(/&/g,'&')); else return;
  155.     asyncSetPI(1);
  156. }
  157. // Move or copy a file or folder
  158. function moveFile(idSource, idDest, copy){
  159.     if(idSource=='mainTree_outer') return;// WA for problem resizing folders treeview
  160.  
  161.     if(idSource==idDest || !dgi(idSource) || !dgi(idDest)) return;
  162.  
  163.     var tn,srcLabel,destLabel,destPath,action;
  164.     if(tn=treeNodeChecked(idDest)) {
  165.         destPath=tn.getPath();
  166.         destLabel=destPath.replace(/\*resourceBasePath\*/,'');
  167.         destPath+='/'+dgi(idSource).innerHTML;
  168.     }
  169.     else{
  170.         destLabel=dgi(idDest).innerHTML;
  171.         destPath=dgi(idDest).innerHTML+'/'+dgi(idSource).innerHTML
  172.         destPath=destPath.replace(/ /g,' ');
  173.     }
  174.     srcLabel=dgi(idSource).innerHTML.replace(/ /,' ');
  175.     destLabel=destLabel.replace(/ /g,' ').replace(/&/g,'&');
  176.  
  177.     if(copy){
  178.         if(!confirm(efCaptGenConfirmCopy.replace('%1',srcLabel).replace('%2',destLabel))) return;
  179.         action='cpy';
  180.     }
  181.     else{
  182.         if(!confirm(efCaptGenConfirmMove.replace('%1',srcLabel).replace('%2',destLabel))) return;
  183.         action='ren';
  184.         if(dgi("_"+idSource)) dgi("f"+idSource.substring(2)).style.visibility="none";
  185.         else dgi("c"+idSource.substring(2)).style.visibility="none";
  186.  
  187.         // Cancel return-to-position animation
  188.         if(dd && dd.elements[idSource]) dd.elements[idSource].cancelAnim=1;
  189.         if(dd && dd.elements['_'+idSource]) dd.elements['_'+idSource].cancelAnim=1;
  190.     }
  191.  
  192.     fas(dgi(idSource).innerHTML, action, destPath);
  193.     asyncSetPI(1);
  194. }
  195. // Create a folder
  196. function newFolder(id) {
  197.     newName=prompt(efCaptExplorerEnterFolderName,"");
  198.     if ((newName) && (newName!="")) fas(newName,"newFolder", "","");
  199. }
  200. // Sort files
  201. function srt(field, order){
  202.     D.forms['comForm'].elements['data1'].value=field;
  203.     asyncSetPI(1);
  204.     fas(order,"srt","","",(W.filesListDisplayed&&filesListDisplayed!='resource')?'async':undefined);
  205. }
  206. // execute a file on server
  207. function exe(id) {
  208. var now = new Date(); var windowName="exec"+now.getTime();
  209. parameters=prompt(efCaptExplorerEnterParameters,"");
  210. if (parameters==false || parameters) {
  211.     W.open("about:blank",windowName, "toolbar=no,location=no,status=yes,scrollbars=no,resizable=no,menuBar=no,width=400,height=200");
  212.     D.forms['comForm'].target=windowName;
  213.     fas(dgi(id).innerHTML, "exe",parameters,"");
  214.     D.forms['comForm'].target='';
  215.     }
  216. }
  217. // Update transfers iframe
  218. function updateTransfersIframe(reupdate){
  219.     frames["transfersIFrame"].refresh(reupdate);
  220. }
  221. // Download file (id must be "idXXX")
  222. function dl(id){
  223.     if(dragCancelOnclick) {dragCancelOnclick=false; return;}
  224.     var fileName;
  225.     if(dgi(id)) fileName=dgi(id).innerHTML; else fileName=id;
  226.     var dlToken="";
  227.     for(var i=0;i<D.comForm.elements['data1'].value.length;i++) dlToken+=D.comForm.elements['data1'].value.charCodeAt(i);
  228.     for(var i=0;i<fileName.length;i++) dlToken+=fileName.charCodeAt(i);
  229.  
  230.     var targetURL="/dl/dlToken"+dlToken+'/resId'+resId+'/'+D.comForm.elements['data1'].value+'/'+fileName;
  231.     D.location.href=targetURL.replace(/#/gi,"*weezoSharp*").replace(/\&/gi,"*weezoAmp*").replace(/\+/gi,"*weezoPlus*").replace(/\%/gi,"*weezoPercent*").replace(/ /gi,"%20");
  232.     if(dgi("transfersIFrame")) setTimeout("updateTransfersIframe()",1000);
  233. }
  234.  
  235. // View file
  236. function view(id,width,height,action) {
  237.     if(W.dragCancelOnclick && dragCancelOnclick) {dragCancelOnclick=false; return;}
  238.     var forceAsync=false;
  239.     var winTitle=((dgi(id))?dgi(id).innerHTML:id);
  240.     if(!action) action="view";
  241.  
  242.     // Special: m3u playlist downloaded to browser
  243.     if(action=='forceM3U'){
  244.         fas(((dgi(id))?dgi(id).innerHTML:id),'view',"forceM3U",false,'sync');
  245.         return;
  246.     }
  247.  
  248.     // Inline player
  249.     if(phpRVarInlinePlayer) {
  250.         fas(((dgi(id))?dgi(id).innerHTML:id),action,"firstLoad",width+"x"+height,forceAsync);
  251.         D.comForm.target='';
  252.         return;
  253.     }
  254.     // Frameless theme : sync open in same window
  255.     if(!winFrames) {D.comForm.target="";forceAsync="sync";}
  256.     else if(noPopup && winUseWindows){
  257.         if(parent.dgi('viewWindow'+resId) && parent.dgi('viewWindow'+resId).innerHTML!=""){
  258.             parent.win("viewWindow"+resId).bringToFront();
  259.         }
  260.         else{
  261.             var w=parent.dd.getWndW();
  262.             var h=parent.dd.getWndH();
  263.             if(!width) width=Math.min(Math.floor(5*w/6),640);
  264.             if(!height) height=Math.min(Math.floor(5*h/6),480);
  265.             parent.winOpenLocation("","viewWindow"+resId,"Weezo",winMyId);
  266.             with(parent.win("viewWindow"+resId)){
  267.                 setReloadType('POST');
  268.                 moveTo(Math.floor((w-width)/2),Math.floor((h-height)/2));
  269.                 resizeInnerTo(width,height);
  270.                 show();
  271.                 bringToFront();
  272.             }
  273.         }
  274.         parent.win("viewWindow"+resId).setCaption(winTitle);
  275.         D.comForm.target=parent.dgi('viewWindow'+resId+'_if').name;
  276.     }
  277.     else{
  278.         var w=screen.availWidth;
  279.         var h=screen.availHeight;
  280.         if(!width) width=Math.floor(2*w/3);
  281.         if(!height) height=Math.floor(2*h/3);
  282.         W.open("about:blank","viewWindow"+resId, "toolbar=no,location=no,status=yes,resizable=yes,menuBar=no,width="+width+", height="+height+", top="+Math.floor((h-height)/2)+", left="+Math.floor((w-width)/2));
  283.         D.comForm.target='viewWindow'+resId;
  284.     }
  285.     //alert(((dgi(id))?dgi(id).innerHTML:id))
  286.     //fas('zza.bmp',action,"firstLoad",width+"x"+height,forceAsync); D.comForm.target='';
  287.     fas(((dgi(id))?dgi(id).innerHTML:id),action,"firstLoad",width+"x"+height,forceAsync); D.comForm.target='';
  288. }
  289. // Edit file
  290. function edit(id) {
  291.     return view(id,undefined, undefined, "edit");
  292.     if(W.dragCancelOnclick && dragCancelOnclick) {dragCancelOnclick=false;return;}
  293.     W.open("about:blank","editWindow", "toolbar=no,location=no,status=yes,resizable=yes,menuBar=no,width="+(screen.width/2)+", height="+(screen.height/2)+", top=" + (screen.height/4) + ", left=" + (screen.width/4));
  294.     D.forms['comForm'].target='editWindow';
  295.     if(dgi(id)) fas(dgi(id).innerHTML,"edit",false,false); else fas(id,"edit",false,false);
  296.     D.forms['comForm'].target='';
  297. }
  298. // Display images from-to thumbnail, or change items per page
  299. function goThumbnail(id,async){
  300.     if(id==='') return;
  301.     id=""+id;
  302.     if(id.substr(0,3)=='ipp') fas(id.substr(3),"changeItemsPerPage","","",async); else fas(id,"goThumbnail","","",async)
  303. }
  304.  
  305. /**
  306.  * Display go progress indicator
  307.  * set: true to set, false to remove
  308.  */
  309. function asyncSetPI(set){
  310.     if(asyncSetPITO) clearTimeout(asyncSetPITO);
  311.     if(set){
  312.         asyncSetPITO=wl.setTimeout(maskShow,900,1,1,'wait',0,'<img src="/gfx/loading2.gif" alt="">');
  313.         if(W.winMe) winMe.setReloading();
  314.     }
  315.     else {
  316.         if(W.winMe) winMe.setLoaded();
  317.         maskHide();
  318.     }
  319. }
  320. var asyncSetPITO;
  321.  
  322. // change directory
  323. function go(id) {
  324.     if(W.dragCancelOnclick && dragCancelOnclick) {dragCancelOnclick=false; return;}
  325.     var res=(id=='..')?fas('..',"go","",""):fas(dgi(id).innerHTML,"go","","");
  326.     asyncSetPI(1);
  327. }
  328.  
  329. /**
  330.  * Direct Navigation to an absolute or relative path
  331.  * inputId: id of <input> containing relative path OR relative path
  332.  * async: true or undefined to async refresh
  333.  */
  334. function goDirect(inputId,async) {
  335.     var typedFileName=(dgi(inputId))?dgi(inputId).value:inputId;
  336.     if(!typedFileName) typedFileName='.';
  337.     if(dgi(inputId)) dgi(inputId).value="";
  338.     fas(typedFileName,"goDirect",'','',async);
  339.     asyncSetPI(1);
  340. }
  341.  
  342.  
  343. // Go back to previous directory
  344. function goBack(){
  345.     fas('..',"goBack","","")
  346.     asyncSetPI(1);
  347. }
  348.  
  349. /**
  350.  * @desc Insert script used for playlist songs insertion / removal
  351.  *
  352.  */
  353. function plAdd(id){
  354.     if(mIsProcessing) return;
  355.     mProcessing(true);
  356.     fas(((dgi(id))?dgi(id).innerHTML:id),'plAdd',false,false);
  357. }
  358. function plSupp(key){
  359.     if(mIsProcessing) return;
  360.     mProcessing(true);
  361.     fas(false,'plSupp',key,false);
  362. }
  363. function plUp(key){
  364.     if(mIsProcessing) return;
  365.     mProcessing(true);
  366.     fas(false,'plUp',key,false);
  367. }
  368. function plDown(key){
  369.     if(mIsProcessing) return;
  370.     mProcessing(true);
  371.     fas(false,'plDown',key,false);
  372. }
  373. function plPlay(id,w,h){var tmp=D.comForm.data1.value;D.comForm.data1.value='';view(id,w,h);D.comForm.data1.value=tmp;}
  374. function plPlayAll(w,h,forcedFormat){
  375.     var tmp=D.comForm.data1.value;D.comForm.data1.value='';
  376.     if(forcedFormat=='forceM3U')view("*playlist*.m3u",w,h,'forceM3U');
  377.     else view("*playlist*.m3u",w,h);
  378.     D.comForm.data1.value=tmp;
  379. }
  380. function plToggleShuffle(val){fas(false,'plToggleShuffle',val,'');}
  381. // Mainplaylist
  382. function plRefresh(fa){
  383.     buff='';
  384.     if(fa.length==0) {
  385.         dgi("mDlList").innerHTML='<center style="width:99%;margin-top:'+(dgi("mDlList").offsetHeight/2-10)+'px">'+efCaptExplorerAudioNoSongInPlayList+'</center>';
  386.         dgi("mDlList").style.overflow='visible';
  387.         return;
  388.     }
  389.     dgi("mDlList").style.overflow='scroll';
  390.     for(var i=0;i<fa.length;){
  391.         buff+='<div id="_id'+seqId+'" class="eTC" eH=1 style="width:99%;position:relative" nowrap="nowrap">';
  392.         buff+=dgi("plPlayBt").innerHTML.replace(/ITEMID/g,'id'+seqId);
  393.         buff+=dgi("plSuppBt").innerHTML.replace(/ITEMID/g,i/2);
  394.         buff+=fa[i+1];
  395.         buff+='<span id="id'+seqId+'" style="display:none">'+fa[i]+'</span>';
  396.         if(fa.length>2){
  397.             if(i) buff+='<span style="position:absolute;right:0.5em;" onclick="javascript:plUp('+(i/2)+')">'+efIcoUp+'</span>';
  398.             if(i<fa.length-2) buff+='<span style="position:absolute;right:1.8em;cursor:pointer" onclick="javascript:plDown('+(i/2)+')">'+efIcoDown+'</span>';
  399.         }
  400.         buff+='</div>';
  401.         i+=2;
  402.         seqId++;
  403.     }
  404.     dgi("mDlList").innerHTML=buff;
  405. }
  406.  
  407. /**
  408.  * @desc Function called on drop event
  409.  *    idSource: id of dragged object
  410.  *  idDest: id of drop target
  411.  */
  412. function dropFunction(idSource, idDest){
  413.     if(idDest=="mDlList") {
  414.         if(dgi("mDlPlaylist")) plAdd(idSource);
  415.         else mAdd(idSource);
  416.         return;
  417.     }
  418.     if(idDest=='actionsPanel_colTD') return;
  419.     if(idDest=="previewOuterFrame") {preview.set(idSource); return;}
  420.     if(W.moveFile) moveFile(idSource, idDest, mouseEvt && mouseEvt.e && mouseEvt.e.ctrlKey);
  421. }
  422.  
  423. //return a string containing checked files names
  424. function checkedFiles(){
  425.     var i; var fileString="";var fileNameId;
  426.     for(i=0;i<D.getElementsByName('cb').length;i++){
  427.         if(D.getElementsByName('cb')[i].checked==true) {
  428.             fileNameId=D.getElementsByName('cb')[i].id
  429.             fileNameId=fileNameId.substring(2,fileNameId.length)
  430.             fileString+='f="'+dgi('id'+fileNameId).innerHTML+'" ';
  431.         }
  432.     }
  433.     return fileString;
  434. }
  435.  
  436. // Comments edition
  437. function saveComments(){
  438.     var commentText=dgi('efCommentsTextArea').value.replace(/\n/gi,"<br />"); // "
  439.     fas(dgi('efPreviewFileName').innerHTML, "saveComments", commentText,"",true);
  440. }
  441.  
  442.  
  443. // Sync/Async thumbnails update monitoring function
  444. function tnUpdt(t,p){
  445.     dgi('tnMonitoringDiv').style.display='';
  446.     progressSetText('tnProg',t);
  447.     progressSetPerc('tnProg',p);
  448. }
  449.  
  450.  
  451. /**
  452.  * Explorer files list or icons view
  453.  */
  454. var filesListElts=[];
  455. function FilesList(files,layout,nodeId,tnw,curDir){
  456.     this.files=files; // List of files (Cf. efFilePropertiesToJSArray) for format
  457.     this.dir=curDir; // Current directory, resoure-path relative
  458.     this.layout=layout; // Layout type: 'icons', 'list', 'customIcons' or 'resource'
  459.     this.nodeId=nodeId; // Id of container node
  460.     this.tnw=tnw; // Current thumbnails width
  461.     this.nb=files.length; // Nb of files
  462.     this.cl=0;
  463.     this.selectedId=0;
  464.     this.UID=100*Math.random();
  465.     this.noTooltip=0;
  466.     this.contextMenuExtra; // Function called to modify context menu
  467.  
  468.     // Dynamic drag object creation
  469.     this.sDF=function(n,DHTMLOptions){
  470.         var p,i=n.id;
  471.         if(i.substr(0,1)=='_'){p=i.substr(0,3);i=i.substr(3)} else{p=i.substr(0,2);i=i.substr(2)}
  472.         if(dd.elements[p+i]) return;
  473.         if(n.style.position!='absolute') n.style.position='relative';
  474.         if(DHTMLOptions) dragItem=p+i+DHTMLOptions;
  475.         else dragItem=p+i+INERTIA+CURSOR_HAND+ELASTIC+DETACH+PICKDELAY+400;
  476.         if(dd.ie) {try{ADD_DHTML(dragItem,1);} catch(err){};} else ADD_DHTML(dragItem,1);
  477.         // Add item to created DHTML elements list so it can be removed before next .draw()
  478.         filesListElts.push(p+i)
  479.     }
  480.  
  481.     // Onload and onerr callbacks
  482.     this.lo=function(e,err){
  483.         e=e||event;
  484.         n=e.currentTarget||e.srcElement;
  485.         if(n&&!err) {
  486.             var ns=n.nextSibling;
  487.             if(ns) {
  488.                 if(ns.src.indexOf('icoM3U')!=-1||ns.src.indexOf('icoMus')!=-1)    ns.src=efOverMus;
  489.                 else if(ns.src.indexOf('icoVid')!=-1) ns.src=efOverVid;
  490.                 else removeNode(n.nextSibling);
  491.             }
  492.             n.style.visibility=''
  493.         }
  494.         setTimeout('fL.l()',1);
  495.     }
  496.     this.le=function(e){fL.lo(e,1)}
  497.  
  498.     // Thumbnail onload function
  499.     this.l=function(n,err){
  500.         while(this.cl<this.nb){
  501.             // If image has alt, put it into src and wait for it to be loaded
  502.             if(dgi('f'+this.cl) && (n=dgi('f'+this.cl).firstChild.firstChild) && n.alt){
  503.                 this.cl++;
  504.                 n.onload=this.lo;
  505.                 n.onerror=this.le;
  506.                 n.src=n.alt;
  507.                 n.alt='';
  508.                 break;
  509.             }
  510.             this.cl++;
  511.         }
  512.     }
  513.  
  514.     // Detect wether right-click is done over an element
  515.     this.onrightclick=function(e){
  516.         var t=e?e.target:event.srcElement;
  517.         var l=10; while(--l>0 && t) {
  518.             if(t.id && (t.id=='filesTable'||t.id=='contextMenu'||t.id=='maskDiv')) return false;
  519.             t=t.parentNode;
  520.         }
  521.         return true;
  522.     }
  523.  
  524.     /**
  525.      *  Left click or context menu
  526.      */
  527.     this.cm=function(n,e){
  528.         var o,f,rc=((e && e.which == 3)||(W.event && event.button == 2)); // right-click
  529.         var isDir=(n.id.substr(0,1)=='d'); // right-clicked file is directory
  530.         var nid=(n.id.substr(0,3)=='_id')?n.id.substr(3):n.id.substr(1);
  531.         var id='id'+nid;
  532.  
  533.         // Left click
  534.         if(!rc){
  535.             if(o=dd.obj){
  536.                 if(o.pickTime()>350 || Math.abs(o.x-o.pickX)>10 || Math.abs(o.y-o.pickY)>10) return;
  537.             }
  538.             if(this.previewOnCM){
  539.                 if(typeof this.previewOnCM=='function') this.previewOnCM(id);
  540.                 else if(W.preview) preview.set(id); // If (image) preview function is present, call it
  541.             }
  542.             if(this.noLeftClickCM) return; // If no left-click context menu, exit
  543.         }
  544.  
  545.         var pl=dgi('mDlPlaylist')?1:0; // A playlist drop-box is present (context menu will display "play" instead of "view"
  546.         if(isDir && !rc) {go(id);return};
  547.         f=this.files[nid];
  548.  
  549.         var cmi=new Array();
  550.         if(isDir) {
  551.             cmi[0]=ContextMenuItem(false,efCaptOpen,'go(fL.selectedId)',1);
  552.             cmi[1]=ContextMenuItem('sep');
  553.         }
  554.         // Downloadable
  555.         if(f[7]){
  556.             v=(f[18]=='v'||f[18]=='a'||f[5].indexOf('icoM3U')!=-1)||(f[5].indexOf('icoMus')!=-1)||(f[5].indexOf('icoVid')!=-1);
  557.             cmi.push(v?ContextMenuItem(efIcoPlay,efCaptPlay,'view(fL.selectedId)',1):ContextMenuItem(efIcoView,efCaptView,'view(fL.selectedId)',1));
  558.             // Download shortcut allowed
  559.             if(f[7]==2){
  560.                 cmi.push(ContextMenuItem('sep'))
  561.                 cmi.push(ContextMenuItem(efIcoDl,efCaptDl,'dl(fL.selectedId)'))
  562.             }
  563.         }
  564.         if(f[8]||pl) {cmi.push(ContextMenuItem(efIcoMAdd,efCaptMAdd,((pl)?'plAdd':'mAdd')+'(fL.selectedId)')); cmi.push(ContextMenuItem('sep'))}
  565.         if(f[6]) cmi.push(ContextMenuItem(efIcoEdit,efCaptEdit,'edit(fL.selectedId)'));
  566.         if(f[13]) cmi.push(ContextMenuItem(efIcoRen,efCaptRen,'ren(fL.selectedId)'));
  567.         if(f[14]) cmi.push(ContextMenuItem(efIcoExe,efCaptExe,'exe(fL.selectedId)'));
  568.         if(f[12]) {cmi.push(ContextMenuItem('sep'));cmi.push(ContextMenuItem(efIcoSup,efCaptSup,'sup(fL.selectedId)'))}
  569.  
  570.         if(this.contextMenuExtra) this.contextMenuExtra(cmi) // If custom preview menu function, pass generated menu to function
  571.  
  572.         this.selectedId='id'+n.id.substr((n.id.substr(0,1)=='f')?1:3);
  573.         if(!rc && (cmi.length==(1+(isDir?1:0)))) eval(cmi[0]['action']); // Single item & left click, click-on
  574.         else var cm=new ContextMenu(cmi,{'fade':1,'centerFirst':!rc}); // else, show context menu
  575.     }
  576.  
  577.     // Tooltip
  578.     this.tt=function(n){
  579.         if((W.dragInProgress && dragInProgress)) return false;
  580.         if(n.tagName=='TD') n=n.parentNode;
  581.         id=n.id
  582.         this.selectedId='id'+id.substr(1);
  583.         fas(dgi('id'+id.substr(1)).innerHTML,'getFileInfo',1,false,'async');
  584.         return '<img id="tooltipLoading" src="'+loadingIconURL+'">';
  585.     }
  586.  
  587.     /* Mouse (h)over / mouse out icon */
  588.     this.mSel=0;
  589.     this.mH=function(n){
  590.         if(this.mSel&&this.mSel!=n) fL.mO(this.mSel); this.mSel=n;
  591.         $(n).e.className().add('itemSel');
  592.         tooltipDelay=2000;
  593.         if(!this.noTooltip) tooltip(n,fL.tt)
  594.     }
  595.     this.mO=function(n){$(n).e.className().remove('itemSel')}
  596.  
  597.     /**
  598.      * Single thumbnail HTML
  599.      */
  600.     this.iconHTML=function(f,i,tnw,tnh){
  601.         var bw=Math.max(Math.ceil(tnw/15),5),fsw=tnw+4*bw;fsh=tnh+4*bw+0;
  602.         var u='<fieldset class="filesIcon" id="'+((f[1]=='d')?'d':'f')+i+'" onmouseup="fL.cm(this,event)" onmouseout="fL.mO(this)" onmouseover="fL.mH(this)" style="width:'+fsw+'px;padding:0px;overflow:hidden">';
  603.         // Image
  604.         if(f[15]) {
  605.             u+='<div class="img" id="_id'+i+'" style="width:'+(f[16]+2*bw+2)+'px;height:'+(f[17]+2*bw+2)+'px;margin-top:'+(bw+(tnh-f[17])/2)+'px;margin-bottom:'+((tnh-f[17])/2)+'px;margin-left:'+(bw+(tnw-f[16])/2-1)+'" onmousedown="fL.sDF(this)">';
  606.             u+='<img alt="'+f[15]+'" style="width:'+f[16]+'px;height:'+f[17]+'px;margin-left:'+bw+'px;margin-top:'+bw+'px;visibility:hidden">';
  607.         }
  608.         // 32x32 icon
  609.         else{
  610.             u+='<div id="_id'+i+'" style="position:relative;width:'+(tnw+18)+'px;height:'+(tnh+12)+'px;top:5px;padding:0px;margin:0px" onmousedown="fL.sDF(this)">';
  611.             u+='<img style="position:relative;top:'+(4+Math.floor((tnh-32)/2))+';left:'+(Math.floor((tnw+18-32)/2))+'" src="'+((f[1]=='d')?efFolderIconM:f[5])+'">';
  612.         }
  613.         u+='</div>';
  614.         u+='<div class="fIC" id="id'+i+'" style="width:'+fsw+'px">'+f[2]+'</div>';
  615.         return u+'</fieldset>';
  616.         //+fsh+'/'+tnh+' bw='+bw;
  617.     }
  618.  
  619.     /**
  620.      * Create layout
  621.      */
  622.     this.draw=function(){
  623.         var tnw=this.tnw, f,o,u,tnh=Math.floor(tnw*3/4);
  624.  
  625.         // Remove previous DHTML elements from dd.elements
  626.         for(o=0;o<filesListElts.length;o++) dd.elements[filesListElts[o]].del();
  627.         filesListElts=[];
  628.  
  629.         if(W.filesListBeforeDraw) filesListBeforeDraw(this.files,tnw,tnh);
  630.  
  631.         // Icons layout
  632.         if(this.files.length==0) o='<table id="filesTable" style="text-align:center;width:100%;height:95%"><tr><td style="vertical-align:middle;height:10em">'+efCaptNoFile+'</td></tr></table>';
  633.         else if(layout=='icons') {
  634.             o='<div id="filesTable" style="text-align:left">';
  635.             for(var i=0;i<this.files.length;i++){
  636.                 o+=this.iconHTML(this.files[i],i,tnw,tnh);
  637.             }
  638.             o+='</div>';
  639.         }
  640.         // Files layout
  641.         else if(layout=='list') {
  642.             o='<table id="filesTable" onmousemove="eHover(event)" onmouseout="eHover()" style="text-align:right" cellspacing=0 cellpadding=0 width="100%"><colgroup><col width="20"><col width="*"><col width="40"><col width="40"><col width="40"></colgroup>';
  643.             for(var i=0;i<this.files.length;i++){
  644.                 f=this.files[i];
  645.                 o+='<tr class="eTC '+((i%2)?'even':'odd')+'" eH=1 id="'+((f[1]=='d')?'d':'f')+i+'" onmouseup="fL.cm(this,event)">';
  646.                 o+='<td onmouseover="tooltip(this,fL.tt)" class="eTCLeft"><img src="'+((f[1]=='d')?efFolderIcon:f[5])+'" alt="" style="height:16">  </td>'; // Icon
  647.                 o+='<td style="text-align:left;overflow:hidden"><span id="id'+i+'" onmousedown="fL.sDF(this)" class="mainCapt">'+f[2]+'</span></td>';// Name
  648.                 o+='<td> '+f[9]+'</td>'; // Size
  649.                 o+='<td>   '+f[10]+'</td>'; // date
  650.                 o+='<td>   '+f[11]+'</td>';
  651.                 o+='</tr>';
  652.             }
  653.             o+='</table>'
  654.         }
  655.         // 'resource' / 'customIcons'
  656.         else {
  657.             o=filesLayoutResource(files,tnw,tnh);
  658.         }
  659.  
  660.         if(!this.nodeId) D.write(o); else dgi(this.nodeId).innerHTML=o;
  661.         if(this.layout!='list') for(i=0;i<5;i++) this.l()
  662.  
  663.         if(W.filesListAfterDraw) filesListAfterDraw(this.files,tnw,tnh);
  664.     }
  665. }
  666. // Change thumnnails size factor, -1 to disable
  667. function efTNSize(s){
  668.     if(!dgi('efTNSize0')) return;
  669.     var updt=s!==undefined && s!==-1;
  670.     if(s===undefined) s=W.thumbnailsSizeFactor;
  671.     var as; if(W.filesListDisplayed&&filesListDisplayed!='resource') as='async';
  672.     wl.button.enable(dgi('efTNSize0'),s!==0&&s!=-1);
  673.     wl.button.enable(dgi('efTNSize1'),s!==1&&s!=-1);
  674.     wl.button.enable(dgi('efTNSize2'),s!==2&&s!=-1);
  675.     if(updt) {thumbnailsSizeFactor=s;fas(0,'efTNSize',s,0,as)}
  676. }
  677.  
  678.  
  679. /**
  680.  * Image Preview Class
  681.  */
  682. function PreviewImage(){
  683.     this.imgIndex=0;
  684.     this.id='id0';
  685.     this.filename='';
  686.     this.imgLastWH;
  687.     this.next='';
  688.     this.prev='';
  689.     this.angle=0;
  690.     this.fileViewAllowed=1;
  691.     this.slideShowActive=0;
  692.     this.slideShowTimer=0;
  693.     this.lastSet='';
  694.     this.commentsEdit; // Comments edit mode, 0/1
  695.     this.comments; // Comments
  696.     this.ctrlsTO=0;// next/prev photo buttons fade-out timer
  697.  
  698.     this.set=function(id){
  699.         if(dd && dd.obj) dd.obj.cancelAnim=1;
  700.         if(dragCancelOnclick) {dragCancelOnclick=false;return;}
  701.  
  702.         if(typeof(id)=='object' && id.id) id=id.id;
  703.         if(!id) id=this.id;
  704.         this.id=id;
  705.         var fn=(dgi(id))?dgi(id).innerHTML:id,pOF=dgi('previewOuterFrame'),lS;
  706.         lS=((pOF)?pOF.offsetWidth+'/'+pOF.offsetHeight:'0/0')+'/'+fn;
  707.         if(lS!=this.lastSet){
  708.             if(pOF) {
  709.                 fas(fn,'preview',pOF.offsetWidth,pOF.offsetHeight,true);
  710.             }
  711.             else {
  712.                 fas(fn,'preview',0,0,true);
  713.             }
  714.             this.lastSet=lS
  715.         }
  716.     }
  717.  
  718.     this.updateSrc=function(s,w,h){
  719.         var i=1-this.imgIndex;
  720.         var pOF=dgi('previewOuterFrame'), ePI=dgi('previewImg'+i);
  721.         if(!pOF) return;
  722.         if(!ePI){
  723.             ePI=D.createElement('IMG');
  724.             ePI.id='previewImg'+i;
  725.             ePI.onclick=function(){preview.view()};
  726.             ePI.style.visibility='hidden';
  727.             ePI.style.zIndex=1;
  728.             pOF.insertBefore(ePI,pOF.firstChild);
  729.         }
  730.         with(ePI.style){
  731.             visibility='hidden';
  732.             display='block';
  733.             width=w;
  734.             height=h;
  735.             left=(pOF.offsetWidth-w)/2;
  736.             top=(pOF.offsetHeight-h)/2;
  737.         }
  738.         ePI.onload=function(){preview.switchImages()};
  739.         ePI.src=s;
  740.     }
  741.     this.setFilename=function(f){this.filename=f}
  742.     this.setTitle=function(t){var n=dgi('previewTitle');if(n) n.innerHTML=t}
  743.  
  744.     this.commentsSet=function(c){
  745.         if(c!==undefined)this.comments=c;
  746.         c=this.comments;
  747.         if(!dgi('efCommentsFrame')) return;
  748.         var i,o='',t=[0,1,-1,0,0,1],l=[0,0,0,1,-1,1];
  749.         for(i=5;i>=0;i--) o+='<div style="position:absolute;text-align:center;width:100%;color:#'+((i)?'555':'FFF')+';top:'+t[i]+'px;left:'+l[i]+'px">'+c+'</div>';
  750.         dgi('efCommentsFrame').innerHTML=o
  751.         dgi('efCommentsTextArea').value=c.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/<br\/>/g,"\n");
  752.     }
  753.     this.commentsToggle=function(){
  754.         var e=this.commentsEdit=1-this.commentsEdit;
  755.         dgi('editStartBt').style.display=dgi('efCommentsFrame').style.display=(e)?'none':''
  756.         dgi('editStopBt').style.display=dgi('efCommentsForm').style.display=(e)?'':'none'
  757.         fas(efEditMode,'toggleComments','','',true);
  758.         this.commentsSet();
  759.         if(e) dgi('efCommentsTextArea').focus();
  760.     }
  761.     this.commentsSave=function(){
  762.         var c=dgi('efCommentsTextArea').value.replace(/\r\n/g,'<br>');
  763.         fas(this.filename,'commentsSave',c,0,'async')
  764.     }
  765.  
  766.     this.currentImg=function(){return dgi('previewImg'+this.imgIndex)}
  767.     this.switchImages=function(){
  768.         if(dgi('previewImg'+this.imgIndex)) fade(dgi('previewImg'+this.imgIndex),1,0);
  769.         this.imgIndex=1-this.imgIndex;
  770.         fade(dgi('previewImg'+this.imgIndex),0,1);
  771.     }
  772.     this.frameResized=function(){
  773.         var pOF=dgi('previewOuterFrame'),i,lw,lh,r,rr,ePI;
  774.         var pOFw=pOF.offsetWidth,pOFh=pOF.offsetHeight,nw,nh;
  775.         if(this.imgLastWH==pOFw+pOFh || pOF.style.display=='none' || !pOFw || !pOFh) return;
  776.         this.imgLastWH=pOFw+pOFh;
  777.  
  778.         for(i=0;i<2;i++) if(ePI=dgi('previewImg'+i)){
  779.             lw=ePI.offsetWidth;
  780.             lh=ePI.offsetHeight;
  781.             r=lw/lh,rr=pOFw/pOFh;
  782.             if(r>rr){nw=pOFw;nh=height=pOFw/r;} else {nh=pOFh;nw=width=pOFh*r}
  783.             if(lw*lh) with(ePI.style) {
  784.                 width=nw;height=nh;
  785.                 left=(pOFw-nw)/2;top=(pOFh-nh)/2
  786.             }
  787.             if(i==this.imgIndex && (nw>lw||nh>lh) && ePI.src) this.set();
  788.         }
  789.     }
  790.  
  791.     this.view=function(id) {if(this.fileViewAllowed) view(id)}
  792.  
  793.     this.goNext=function() {this.set(this.next)}
  794.     this.clickNext=function() {setAlpha(dgi('previewNextBt'),1);fade(dgi('previewNextBt'),1,0.7,40);preview.ctrlsTOReset(1);this.goNext()}
  795.  
  796.     this.goPrev=function() {this.set(this.prev)}
  797.     this.clickPrev=function() {setAlpha(dgi('previewPrevBt'),1);fade(dgi('previewPrevBt'),1,0.7,40);preview.ctrlsTOReset(1);this.goPrev()}
  798.  
  799.     this.rotateLeft=function(){fas(this.filename,'rotate'+((this.angle>0)?(this.angle-90):270),dgi("previewOuterFrame").offsetWidth,false,true);}
  800.     this.rotateRight=function(){fas(this.filename,'rotate'+((this.angle==270)?0:this.angle+90),dgi("previewOuterFrame").offsetWidth,false,true);}
  801.     this.dl=function(){dl(this.id)}
  802.     this.mAdd=function(){mAdd(this.id)}
  803.  
  804.     this.ctrlsTOReset=function(mi){
  805.         if(this.ctrlsTO) clearTimeout(preview.ctrlsTO);
  806.         this.ctrlsTO=0;this.ctrlsTO=setTimeout('preview.ctrlsHide()',((mi)?8000:3000))
  807.     }
  808.     this.ctrlsShow=function(){
  809.         wl.fadeTo('previewNextBt',0.7,10);
  810.         wl.fadeTo('previewPrevBt',0.7,10);
  811.         this.ctrlsTOReset(1);
  812.     }
  813.     this.ctrlsHide=function(){
  814.         if(preview.ctrlsTO) clearTimeout(preview.ctrlsTO); preview.ctrlsTO=0;
  815.         wl.fadeTo('previewNextBt',0,60);
  816.         wl.fadeTo('previewPrevBt',0,60);
  817.     }
  818.     this.ctrlsMouseOut=function(){this.ctrlsTOReset(0)}
  819.  
  820.     // Slideshow
  821.     this.toggleSlideshow=function(){
  822.         this.slideShowActive=1-this.slideShowActive;
  823.         dgi('slideShowStartButton').style.display=(this.slideShowActive)?'none':'';
  824.         dgi('slideShowStopButton').style.display=(this.slideShowActive)?'':'none';
  825.         if(this.slideShowActive==1) this.slideShowTimer = W.setInterval("preview.goNext()",slideShowInterval);
  826.         else W.clearInterval(this.slideShowTimer);
  827.     }
  828. }
  829.  
  830. // Prevent backspace key to go back to previous page (instead try goBack function)
  831. wl.blockBackspace();